"""gmooc URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/2.1/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""

from django.urls import path, include
from django.views.generic import TemplateView
from django.views.static import serve
import xadmin

from users.views import LoginView, RegisterView, ActiveUserView, ForgetPwdView, ResetUserView, ModifyPwdView
from organization.views import OrgView

from django.conf import settings
from django.conf.urls.static import static


# 首页
class IndexPageView(TemplateView):
    template_name = "index.html"


urlpatterns = [
    # 后台管理系统
    path('xadmin/', xadmin.site.urls, name="admin"),
    # 首页
    path('', IndexPageView.as_view(), name='index'),
    # 用户登录
    path('login/', LoginView.as_view(), name='login'),
    # 用户注册
    path('register/', RegisterView.as_view(), name='register'),
    # 验证码路径
    path('captcha/', include('captcha.urls')),
    # 用户激活(提取url中的变量)
    path('active/<active_code>', ActiveUserView.as_view()),
    # 找回密码
    path('forget/', ForgetPwdView.as_view(), name="forget_pwd"),
    # 找回密码激活(提取url中的变量)
    path('reset/<active_code>', ResetUserView.as_view(), name="reset_pwd "),
    # 重置密码
    path('modify_pwd/', ModifyPwdView.as_view(), name="modify_pwd"),

    # 课程机构
    path('org/', include('organization.urls'))

] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)  # 配置上传文件访问

